<?php

/**
 * formproblemevehicule filter form base class.
 *
 * @package    forumCDE
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseformproblemevehiculeFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'dossier_id'               => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('dossier'), 'add_empty' => true)),
      'codevehicule_id'          => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('codevehicule'), 'add_empty' => true)),
      'eclatparabrise'           => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'commentaire'              => new sfWidgetFormFilterInput(),
      'created_at'               => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'updated_at'               => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'problemepneumatique_list' => new sfWidgetFormDoctrineChoice(array('multiple' => true, 'model' => 'problemepneumatique')),
      'positioneclairage_list'   => new sfWidgetFormDoctrineChoice(array('multiple' => true, 'model' => 'positionprobleme')),
      'problememoteur_list'      => new sfWidgetFormDoctrineChoice(array('multiple' => true, 'model' => 'problememoteur')),
      'problemeniveau_list'      => new sfWidgetFormDoctrineChoice(array('multiple' => true, 'model' => 'problemeniveau')),
      'problemecarrosserie_list' => new sfWidgetFormDoctrineChoice(array('multiple' => true, 'model' => 'problemecarrosserie')),
      'problemeeclairage_list'   => new sfWidgetFormDoctrineChoice(array('multiple' => true, 'model' => 'problemeeclairage')),
      'problemefreins_list'      => new sfWidgetFormDoctrineChoice(array('multiple' => true, 'model' => 'positionprobleme')),
      'positioncarrosserie_list' => new sfWidgetFormDoctrineChoice(array('multiple' => true, 'model' => 'positionprobleme')),
      'positionpneumatique_list' => new sfWidgetFormDoctrineChoice(array('multiple' => true, 'model' => 'positionprobleme')),
    ));

    $this->setValidators(array(
      'dossier_id'               => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('dossier'), 'column' => 'id')),
      'codevehicule_id'          => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('codevehicule'), 'column' => 'id')),
      'eclatparabrise'           => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'commentaire'              => new sfValidatorPass(array('required' => false)),
      'created_at'               => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'updated_at'               => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'problemepneumatique_list' => new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'problemepneumatique', 'required' => false)),
      'positioneclairage_list'   => new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'positionprobleme', 'required' => false)),
      'problememoteur_list'      => new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'problememoteur', 'required' => false)),
      'problemeniveau_list'      => new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'problemeniveau', 'required' => false)),
      'problemecarrosserie_list' => new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'problemecarrosserie', 'required' => false)),
      'problemeeclairage_list'   => new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'problemeeclairage', 'required' => false)),
      'problemefreins_list'      => new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'positionprobleme', 'required' => false)),
      'positioncarrosserie_list' => new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'positionprobleme', 'required' => false)),
      'positionpneumatique_list' => new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'positionprobleme', 'required' => false)),
    ));

    $this->widgetSchema->setNameFormat('formproblemevehicule_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function addProblemepneumatiqueListColumnQuery(Doctrine_Query $query, $field, $values)
  {
    if (!is_array($values))
    {
      $values = array($values);
    }

    if (!count($values))
    {
      return;
    }

    $query
      ->leftJoin($query->getRootAlias().'.link_probpneu_itemform link_probpneu_itemform')
      ->andWhereIn('link_probpneu_itemform.problemepneumatique_id', $values)
    ;
  }

  public function addPositioneclairageListColumnQuery(Doctrine_Query $query, $field, $values)
  {
    if (!is_array($values))
    {
      $values = array($values);
    }

    if (!count($values))
    {
      return;
    }

    $query
      ->leftJoin($query->getRootAlias().'.link_posecl_itemform link_posecl_itemform')
      ->andWhereIn('link_posecl_itemform.positionprobleme_id', $values)
    ;
  }

  public function addProblememoteurListColumnQuery(Doctrine_Query $query, $field, $values)
  {
    if (!is_array($values))
    {
      $values = array($values);
    }

    if (!count($values))
    {
      return;
    }

    $query
      ->leftJoin($query->getRootAlias().'.link_probmoteur_itemform link_probmoteur_itemform')
      ->andWhereIn('link_probmoteur_itemform.problememoteur_id', $values)
    ;
  }

  public function addProblemeniveauListColumnQuery(Doctrine_Query $query, $field, $values)
  {
    if (!is_array($values))
    {
      $values = array($values);
    }

    if (!count($values))
    {
      return;
    }

    $query
      ->leftJoin($query->getRootAlias().'.link_probniveau_itemform link_probniveau_itemform')
      ->andWhereIn('link_probniveau_itemform.problemeniveau_id', $values)
    ;
  }

  public function addProblemecarrosserieListColumnQuery(Doctrine_Query $query, $field, $values)
  {
    if (!is_array($values))
    {
      $values = array($values);
    }

    if (!count($values))
    {
      return;
    }

    $query
      ->leftJoin($query->getRootAlias().'.link_probcarro_itemform link_probcarro_itemform')
      ->andWhereIn('link_probcarro_itemform.problemecarrosserie_id', $values)
    ;
  }

  public function addProblemeeclairageListColumnQuery(Doctrine_Query $query, $field, $values)
  {
    if (!is_array($values))
    {
      $values = array($values);
    }

    if (!count($values))
    {
      return;
    }

    $query
      ->leftJoin($query->getRootAlias().'.link_probecl_itemform link_probecl_itemform')
      ->andWhereIn('link_probecl_itemform.problemeeclairage_id', $values)
    ;
  }

  public function addProblemefreinsListColumnQuery(Doctrine_Query $query, $field, $values)
  {
    if (!is_array($values))
    {
      $values = array($values);
    }

    if (!count($values))
    {
      return;
    }

    $query
      ->leftJoin($query->getRootAlias().'.link_probfreins_itemform link_probfreins_itemform')
      ->andWhereIn('link_probfreins_itemform.positionprobleme_id', $values)
    ;
  }

  public function addPositioncarrosserieListColumnQuery(Doctrine_Query $query, $field, $values)
  {
    if (!is_array($values))
    {
      $values = array($values);
    }

    if (!count($values))
    {
      return;
    }

    $query
      ->leftJoin($query->getRootAlias().'.link_poscarro_itemform link_poscarro_itemform')
      ->andWhereIn('link_poscarro_itemform.positionprobleme_id', $values)
    ;
  }

  public function addPositionpneumatiqueListColumnQuery(Doctrine_Query $query, $field, $values)
  {
    if (!is_array($values))
    {
      $values = array($values);
    }

    if (!count($values))
    {
      return;
    }

    $query
      ->leftJoin($query->getRootAlias().'.link_pospneu_itemform link_pospneu_itemform')
      ->andWhereIn('link_pospneu_itemform.positionprobleme_id', $values)
    ;
  }

  public function getModelName()
  {
    return 'formproblemevehicule';
  }

  public function getFields()
  {
    return array(
      'id'                       => 'Number',
      'dossier_id'               => 'ForeignKey',
      'codevehicule_id'          => 'ForeignKey',
      'eclatparabrise'           => 'Boolean',
      'commentaire'              => 'Text',
      'created_at'               => 'Date',
      'updated_at'               => 'Date',
      'problemepneumatique_list' => 'ManyKey',
      'positioneclairage_list'   => 'ManyKey',
      'problememoteur_list'      => 'ManyKey',
      'problemeniveau_list'      => 'ManyKey',
      'problemecarrosserie_list' => 'ManyKey',
      'problemeeclairage_list'   => 'ManyKey',
      'problemefreins_list'      => 'ManyKey',
      'positioncarrosserie_list' => 'ManyKey',
      'positionpneumatique_list' => 'ManyKey',
    );
  }
}
